<template>
  <el-tabs v-model="tabPaneVal" type="border-card" @tab-click="handleClick">
    <el-tab-pane label="车队资料" name="DriverTeamEdit">
      <DriverTeamEdit v-if="isDriverTeamEditShow" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="车队司机" name="TeamDirver">
      <TeamDirver v-if="isTeamDirverShow" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="车队车辆" name="TeamVehicle">
      <TeamVehicle v-if="isTeamVehicleShow" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="常跑线路" name="CommonRouteInfo">
      <CommonRouteInfo v-if="isCommonRouteInfoShow" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="邀请司机" name="InviteTheDriver">
      <InviteTheDriver v-if="isInviteTheDriverShow" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="邀请记录" name="InviteRecord">
      <InviteRecord v-if="isInviteRecordShow" :parent-data="parentData" />
    </el-tab-pane>
    <el-tab-pane label="计价体系" name="PriceSystem">
      <PriceSystem v-if="isPriceSystemShow" :parentData="parentData" />
    </el-tab-pane>
  </el-tabs>
</template>

<script>
import DriverTeamEdit from './components/driverTeamEdit.vue'
import TeamDirver from './components/teamDirver/teamDirverList.vue'
import TeamVehicle from './components/teamVehicle/teamVehicleList.vue'
import CommonRouteInfo from './components/commonRouteInfo/commonRouteInfoList.vue'
import InviteTheDriver from './components/inviteDriver/inviteTheDriver.vue'
import InviteRecord from './components/inviteDriver/inviteRecord.vue'
import PriceSystem from "@/views/basicInfo/priceSystem/priceSystem.vue";
import { SelectAddress } from '@/api/orderform'
import { getListDict } from '@/api/commonApi'
import { getBindList } from '@/api/driver'
export default {
  name: 'SelfDriverTeamForm',
  components: {
    DriverTeamEdit,
    TeamDirver,
    TeamVehicle,
    CommonRouteInfo,
    InviteTheDriver,
    InviteRecord,
    PriceSystem
  },
  data() {
    return {
      parentData: {
        areaOptions: [],
        vehicleBindList: [],
        vehicleTypeAllowList: [],
        vehicleClassificationList: [],
        vehicleLengthList: [],
        vehicleWidthList: [],
        vehicleHighList: [],
        vehicleTonnageList: [],
        locationSourceList: []
      },
      tabPaneVal: 'DriverTeamEdit',
      isDriverTeamEditShow: true,
      isTeamDirverShow: false,
      isTeamVehicleShow: false,
      isCommonRouteInfoShow: false,
      isInviteTheDriverShow: false,
      isInviteRecordShow: false,
      isPriceSystemShow: false,
    }
  },
  created() {
    var partyCode = this.$route.query.partyCode
    SelectAddress().then(response => {
      this.parentData.areaOptions = response.data.records
    })
    getBindList({ pageSize: 1000000, teamCode: partyCode }).then(response => {
      this.parentData.vehicleBindList = response.data.records
    })
    // 获取数据字典： 准驾车型，车型，车长，车宽，车高，吨位，定位来源
    getListDict({
      types:
        'vehicleTypeAllow,vehicleClassification,vehicleLength,vehicleWidth,vehicleHigh,vehicleTonnage,locationSource'
    }).then(response => {
      this.parentData.vehicleTypeAllowList = response.data.filter(
        item => item.type === 'vehicleTypeAllow'
      )[0]['dictList']
      this.parentData.vehicleClassificationList = response.data.filter(
        item => item.type === 'vehicleClassification'
      )[0]['dictList']
      this.parentData.vehicleLengthList = response.data.filter(
        item => item.type === 'vehicleLength'
      )[0]['dictList']
      this.parentData.vehicleWidthList = response.data.filter(
        item => item.type === 'vehicleWidth'
      )[0]['dictList']
      this.parentData.vehicleHighList = response.data.filter(
        item => item.type === 'vehicleHigh'
      )[0]['dictList']
      this.parentData.vehicleTonnageList = response.data.filter(
        item => item.type === 'vehicleTonnage'
      )[0]['dictList']
      this.parentData.locationSourceList = response.data.filter(
        item => item.type === 'locationSource'
      )[0]['dictList']
    })
  },
  methods: {
    handleClick(tab, event) {
      this[`is${tab.name}Show`] = true
    }
  }
}
</script>
